package com.ssy.lingxi.settle.accounts.config;

import com.ssy.lingxi.dto.model.constant.SettleAccountsConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 消息队列配置
 * @author 彭冬冬
 * @version 2.0.0
 * @date 2022/1/17 17:18
 */
@Configuration
public class SettleAccountsConfig {
    //*********************************** 结算服务标准通通知队列 ***********************************
    @Bean
    public DirectExchange baseExchange() {
        return new DirectExchange(SettleAccountsConstant.SETTLE_ACCOUNT_BASE_EXCHANGE, true, true);
    }

    @Bean
    public Queue baseQueue() {
        return new Queue(SettleAccountsConstant.SETTLE_ACCOUNT_BASE_QUEUE, true);
    }

    @Bean
    public Binding baseBinding() {
        return BindingBuilder.bind(baseQueue())
                .to(baseExchange())
                .with(SettleAccountsConstant.SETTLE_ACCOUNT_BASE_ROUTING_KEY);
    }

    //*********************************** 结算服务，添加待对账订单-商品信息通知队列 *****************************************
    @Bean
    public Queue saAutoReconciliationQueue() {
        return new Queue(SettleAccountsConstant.SA_AUTO_RECONCILIATION_QUEUE, true);
    }

    @Bean
    public DirectExchange saAutoReconciliationExchange() {
        return new DirectExchange(SettleAccountsConstant.SA_AUTO_RECONCILIATION_EXCHANGE, true, true);
    }

    @Bean
    public Binding saAutoReconciliationBinding() {
        return BindingBuilder.bind(saAutoReconciliationQueue()).to(saAutoReconciliationExchange()).with(SettleAccountsConstant.SA_AUTO_RECONCILIATION_ROUTINGKEY);
    }

    //*********************************** 结算服务，添加平台结算-通联支付-付款结算信息通知队列， by 彭冬冬 *****************************************
    @Bean
    public DirectExchange saPlatformSettlementAllInPayExchange() {
        return new DirectExchange(SettleAccountsConstant.SA_PLATFORM_SETTLEMENT_ALL_IN_PAY_EXCHANGE, true, true);
    }

    @Bean
    public Queue saPlatformSettlementAllInPayQueue() {
        return new Queue(SettleAccountsConstant.SA_PLATFORM_SETTLEMENT_ALL_IN_PAY_QUEUE, true);
    }

    @Bean
    public Binding saPlatformSettlementAllInRoutingKey() {
        return BindingBuilder.bind(saPlatformSettlementAllInPayQueue()).to(saPlatformSettlementAllInPayExchange()).with(SettleAccountsConstant.SA_PLATFORM_SETTLEMENT_ALL_IN_ROUTING_KEY);
    }
}
